﻿using System.Collections.Generic;
using BestCode.Creds.Data.MapHelper;
using BestCode.Creds.Entities;
using NHibernate.Criterion;

namespace BestCode.Creds.Data
{
    public class FieldDefinitionDao : DaoBase<FieldDefinition>, IFieldDefinitionDao
    {
        public IList<FieldDefinition> GetByFilter(string filter)
        {
            return Session.QueryOver<FieldDefinition>().Where(p => p.Code.IsLike(filter + "%")).List();
        }

        public IList<FieldDefinition> GetByEntityId(int entityId)
        {
            return Session.QueryOver<FieldDefinition>().Where(p => p.Entity.Id == entityId).List();
        }
    }
}
